﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using MusicExplorer.WebRepository;
using System.Windows.Input;
using System;
using MusicExplorer.Data;
using System.Collections;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using MusicExplorer.Wrappers;
using System.Threading.Tasks;
using System.Threading;
using System.Windows;
using MusicExplorer.WebRepository.Interface;
using System.Net;
using MusicExplorer.Internals;
using MusicExplorer.WebRepository.Service;
using System.IO;
using System.Windows.Media;
using MusicExplorer.Helper;

namespace MusicExplorer.ViewModel
{
    public sealed class MainWindowViewModel : ViewModelBase, IDisposable
    {
        #region VIEW MODELS

        private readonly PlayerViewModel m_playerViewModel;
        public PlayerViewModel Player { get { return m_playerViewModel; } }

        private readonly WebRepositoryTreeViewModel m_webRepositoryTreeViewModel;
        public WebRepositoryTreeViewModel WebRepositoryTree { get { return m_webRepositoryTreeViewModel; } }

        private readonly TrackListViewModel m_trackListViewModel;
        public TrackListViewModel TrackList { get { return m_trackListViewModel; } }

        private readonly LogViewModel m_logViewModel;
        public LogViewModel Log { get { return m_logViewModel; } }

        private readonly DetailTreeViewModel m_detailTreeViewModel;
        public DetailTreeViewModel DetailTree { get { return m_detailTreeViewModel; } }

        #endregion

        public MainWindowViewModel()
        {
            m_logViewModel = new LogViewModel(this);
            m_playerViewModel = new PlayerViewModel(this);
            m_webRepositoryTreeViewModel = new WebRepositoryTreeViewModel(this);
            m_trackListViewModel = new TrackListViewModel(this);
            m_detailTreeViewModel = new DetailTreeViewModel(this);
        }

        public void Dispose()
        {
            if (m_detailTreeViewModel != null) m_detailTreeViewModel.Dispose();
            if (m_playerViewModel != null) m_playerViewModel.Dispose();
            if (m_trackListViewModel != null) m_trackListViewModel.Dispose();
        }
    }
}